<template>
  <div>
    <div class="sr-container" style="margin:20px">
      <div class="fliter-container" style="margin-top:15px">
        <span style="margin-left:2%">使用人账户：</span>
        <el-input
          v-model="search.userName"
          placeholder="请输入手机号"
          size="small"
          class="fliter-item"
          style="width:200px"
          @keyup.enter.native="handleFilter"
        ></el-input>
        <span style="margin-left:2%">使用人：</span>
        <el-input
          v-model="search.nickName"
          placeholder="请输入姓名"
          size="small"
          class="fliter-item"
          style="width:200px"
          @keyup.enter.native="handleFilter"
        ></el-input>
        <span style="margin-left:2%">使用时间：</span>
        <el-date-picker
          v-model="search.useDate"
          type="date"
          value-format='yyyy-MM-dd'
          size="small"
          placeholder="选择日期">
        </el-date-picker>
        <el-button
          size="small"
          style="margin-left:3%;"
          class="filter-item"
          type="success"
          icon="el-icon-search"
          @click="handleFilter"
        >查询</el-button>
      </div>
      <!-- 仓库商品列表 -->
      <el-table :data="dataList" style="width: 100%;margin-top:15px" tooltip-effect="dark" border>
        <el-table-column type="index" min-width="50" label="序号" align="center"></el-table-column>
        <el-table-column label="使用人" width="300px" align="center" prop="nickName">
          <template slot-scope="{row}">
            <span>{{row.nickName}}</span>
          </template>
        </el-table-column>
        <el-table-column label="使用人账户" min-width="250px" align="center">
          <template slot-scope="{row}">
            <span>{{row.userName}}</span>
          </template>
        </el-table-column>
        <el-table-column label="优惠券面额" width="150px" align="center">
          <template slot-scope="{row}">
            <span>{{row.ticketVal}}</span>
          </template>
        </el-table-column>
        <el-table-column label="限用商品" width="350px" align="center">
          <template slot-scope="{row}">
            <span>{{row.infoName}}</span>
          </template>
        </el-table-column>
        <el-table-column label="有效期至" width="200px" align="center">
          <template slot-scope="{row}">
            <span>{{row.limitTime}}</span>
          </template>
        </el-table-column>
        <el-table-column label="使用时间" align="center" width="200px">
          <template slot-scope="{ row }">
            <span>{{row.useDate}}</span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="search.pageNum"
        :limit.sync="search.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import { getListPage } from '@/api/lssueRecord'
import Pagination from "@/components/Pagination";

export default {
  inject:["reload"],

  components: { Pagination },
  data() {
    return {
      total:0, 
      reportTotal: 0,
      isReportVisible: false,
      recordData:null,
      isShowAddVisible: false,
      isTransferVisible: false,
      //查询内容
      search: {
        pageNum: 1,
        pageSize: 10,
        useDate: "",
        userName: "",
        nickName: ""
      },
      dataList: [
      ],
    };
  },
  created() {
    this.getList()
    // this.setTable()
  },
  methods: {
  //获取列表数据
    getList() {
      this.listLoading = true
      var params = {
        // pageConvert: true,
        pageNum: this.search.pageNum-1,
        pageSize: this.search.pageSize,
        userName: this.search.userName,
        useDate: this.search.useDate,
        nickName: this.search.nickName
      }
      getListPage(params).then(response => {
        this.dataList = response.data.content
        this.total = response.data.totalElements
        // Just to simulate the time of the request
        this.listLoading = false
      })
    },
    handleFilter() {
      this.search.page = 1
      this.getList()
    },
  }
};
</script>